﻿@{
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();

    var grid = Html.DevExpress().GridView(
        settings =>
        {
            settings.Name = "gvEditing";
            settings.KeyFieldName = "IdTipoCliente";
            settings.CallbackRouteValues = new { Controller = "TipoCliente", Action = "EditTipoClientesPartial" };
            settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "TipoCliente", Action = "EditTipoClientesAddNewPartial" };
            settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "TipoCliente", Action = "EditTipoClientesUpdatePartial" };
            settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "TipoCliente", Action = "EditTipoClientesDeletePartial" };
            settings.SettingsEditing.Mode = GridViewEditingMode.PopupEditForm;
            
            
            settings.SettingsBehavior.ConfirmDelete = true;
            settings.SettingsPopup.EditForm.Width = 600;
            settings.SettingsPopup.EditForm.HorizontalAlign = PopupHorizontalAlign.Center;
            settings.SettingsPopup.EditForm.VerticalAlign = PopupVerticalAlign.WindowCenter;
            settings.SettingsPager.FirstPageButton.Visible = true;
            settings.SettingsPager.LastPageButton.Visible = true;
            settings.SettingsPager.PageSizeItemSettings.Visible = true;
            settings.SettingsPager.PageSizeItemSettings.Items = new string[] { "10", "20", "50" };
            
            
            settings.Settings.ShowFilterRow = true;
            settings.Settings.ShowFilterRowMenu = true;
            settings.CommandColumn.Visible = true;
            settings.CommandColumn.ShowClearFilterButton = true;
            
            settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);

            settings.CommandColumn.Visible = true;
            settings.CommandColumn.ShowNewButtonInHeader = ViewBag.PermisoCreate;
            settings.CommandColumn.ShowEditButton = ViewBag.PermisoEdit;
            settings.CommandColumn.ShowDeleteButton = ViewBag.PermisoDelete;

            settings.Columns.Add("Nombre");

            settings.PreRender = (s, e) =>
            {
                var sender = (MVCxGridView)s;
                sender.FocusedRowIndex = 1;
            };

            settings.SettingsBehavior.AllowFocusedRow = true;
            
        });

    if (ViewData["EditError"] != null){
        grid.SetEditErrorText((string)ViewData["EditError"]);
    }
}

@grid.Bind(Model).GetHtml()














